#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:high_function.py
# author:张仁
# datetime:2021/3/17 13:41
# software: PyCharm
"""
   高阶函数练习
"""


def operation(x, y, f):
    """实现四则运算

    传入两个操作数，和一个运算函数"""
    return f(x, y)


def add(x, y):
    """实现加法运算

    传入两个操作数"""
    return x + y


def reduce(x, y):
    """实现减法运算

    传入两个操作数"""
    return x - y


def multiply(x, y):
    """实现乘法运算

    传入两个操作数"""
    return x * y


def divide(x, y):
    """实现除法运算

    传入两个操作数"""
    return x / y


if __name__ == '__main__':
    one = 5
    two = 6
    # 加法
    print("相加得：", operation(one, two, add))
    # 减法
    print("相减得：", operation(one, two, reduce))
    # 乘法
    print("相乘得：", operation(one, two, multiply))
    # 除法
    print("相除得：", operation(one, two, divide))
